package o.gwtp.editor.client.editor;

import o.gwtp.editor.client.main.MainPresenter;
import o.gwtp.editor.client.navigation.NavigationTabElement;

import com.gwtplatform.mvp.client.EventBus;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ProxyStandard;
import com.gwtplatform.mvp.client.proxy.ProxyPlace;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;

/**
 * @author Olivier Monaco
 */
public class EditorPresenter extends
    Presenter<EditorPresenter.EditorView, EditorPresenter.EditorProxy>
    implements NavigationTabElement {
  @ProxyStandard
  public interface EditorProxy extends ProxyPlace<EditorPresenter> {
  }

  public interface EditorView extends View {
  }

  private String name;

  public EditorPresenter(EventBus eventBus, EditorView view, EditorProxy proxy,
      String name) {
    super(eventBus, view, proxy);
    this.name = name;
  }

  @Override
  public String getName() {
    return name;
  }

  @Override
  public String getToken() {
    return getProxy().getNameToken();
  }

  @Override
  public boolean isClosable() {
    return true;
  }

  @Override
  protected void onReveal() {
    super.onReveal();
  }

  @Override
  protected void revealInParent() {
    RevealContentEvent.fire(this, MainPresenter.CONTENT_SLOT, this);
  }
}
